#include <windows.h>

#define IDSWM(msg) {msg, #msg},
typedef struct
{
    int msg;
    const char* msgdesc;
}Msg2StrMap;

static const Msg2StrMap msgDesc[] = 
{
    IDSWM(WM_NULL                    )
    IDSWM(WM_CREATE                  )
    IDSWM(WM_DESTROY                 )
    IDSWM(WM_MOVE                    )
    IDSWM(WM_SIZE                    )
    IDSWM(WM_ACTIVATE                )
    IDSWM(WM_SETFOCUS                )
    IDSWM(WM_KILLFOCUS               )
    IDSWM(WM_ENABLE                  )
    IDSWM(WM_SETREDRAW               )
    IDSWM(WM_SETTEXT                 )
    IDSWM(WM_GETTEXT                 )
    IDSWM(WM_GETTEXTLENGTH           )
    IDSWM(WM_PAINT                   )
    IDSWM(WM_CLOSE                   )
    IDSWM(WM_QUERYENDSESSION         )
    IDSWM(WM_QUIT                    )
    IDSWM(WM_QUERYOPEN               )
    IDSWM(WM_ERASEBKGND              )
    IDSWM(WM_SYSCOLORCHANGE          )
    IDSWM(WM_ENDSESSION              )
    IDSWM(WM_SHOWWINDOW              )
    IDSWM(WM_WININICHANGE            )
    IDSWM(WM_DEVMODECHANGE           )
    IDSWM(WM_ACTIVATEAPP             )
    IDSWM(WM_FONTCHANGE              )
    IDSWM(WM_TIMECHANGE              )
    IDSWM(WM_CANCELMODE              )
    IDSWM(WM_SETCURSOR               )
    IDSWM(WM_MOUSEACTIVATE           )
    IDSWM(WM_CHILDACTIVATE           )
    IDSWM(WM_QUEUESYNC               )
    IDSWM(WM_GETMINMAXINFO           )
    IDSWM(WM_PAINTICON               )
    IDSWM(WM_ICONERASEBKGND          )
    IDSWM(WM_NEXTDLGCTL              )
    IDSWM(WM_SPOOLERSTATUS           )
    IDSWM(WM_DRAWITEM                )
    IDSWM(WM_MEASUREITEM             )
    IDSWM(WM_DELETEITEM              )
    IDSWM(WM_VKEYTOITEM              )
    IDSWM(WM_CHARTOITEM              )
    IDSWM(WM_SETFONT                 )
    IDSWM(WM_GETFONT                 )
    IDSWM(WM_SETHOTKEY               )
    IDSWM(WM_GETHOTKEY               )
    IDSWM(WM_QUERYDRAGICON           )
    IDSWM(WM_COMPAREITEM             )
    IDSWM(WM_GETOBJECT               )
    IDSWM(WM_COMPACTING              )
    IDSWM(WM_COMMNOTIFY              )
    IDSWM(WM_WINDOWPOSCHANGING       )
    IDSWM(WM_WINDOWPOSCHANGED        )
    IDSWM(WM_POWER                   )
    IDSWM(WM_COPYDATA                )
    IDSWM(WM_CANCELJOURNAL           )
    IDSWM(WM_NOTIFY                  )
    IDSWM(WM_INPUTLANGCHANGEREQUEST  )
    IDSWM(WM_INPUTLANGCHANGE         )
    IDSWM(WM_TCARD                   )
    IDSWM(WM_HELP                    )
    IDSWM(WM_USERCHANGED             )
    IDSWM(WM_NOTIFYFORMAT            )
    IDSWM(WM_CONTEXTMENU             )
    IDSWM(WM_STYLECHANGING           )
    IDSWM(WM_STYLECHANGED            )
    IDSWM(WM_DISPLAYCHANGE           )
    IDSWM(WM_GETICON                 )
    IDSWM(WM_SETICON                 )
    IDSWM(WM_NCCREATE                )
    IDSWM(WM_NCDESTROY               )
    IDSWM(WM_NCCALCSIZE              )
    IDSWM(WM_NCHITTEST               )
    IDSWM(WM_NCPAINT                 )
    IDSWM(WM_NCACTIVATE              )
    IDSWM(WM_GETDLGCODE              )
    IDSWM(WM_SYNCPAINT               )
    IDSWM(WM_NCMOUSEMOVE             )
    IDSWM(WM_NCLBUTTONDOWN           )
    IDSWM(WM_NCLBUTTONUP             )
    IDSWM(WM_NCLBUTTONDBLCLK         )
    IDSWM(WM_NCRBUTTONDOWN           )
    IDSWM(WM_NCRBUTTONUP             )
    IDSWM(WM_NCRBUTTONDBLCLK         )
    IDSWM(WM_NCMBUTTONDOWN           )
    IDSWM(WM_NCMBUTTONUP             )
    IDSWM(WM_NCMBUTTONDBLCLK         )
    IDSWM(WM_KEYDOWN                 )
    IDSWM(WM_KEYUP                   )
    IDSWM(WM_CHAR                    )
    IDSWM(WM_DEADCHAR                )
    IDSWM(WM_SYSKEYDOWN              )
    IDSWM(WM_SYSKEYUP                )
    IDSWM(WM_SYSCHAR                 )
    IDSWM(WM_SYSDEADCHAR             )
    IDSWM(WM_KEYLAST                 )
    IDSWM(WM_IME_STARTCOMPOSITION    )
    IDSWM(WM_IME_ENDCOMPOSITION      )
    IDSWM(WM_IME_COMPOSITION         )
    IDSWM(WM_IME_KEYLAST             )
    IDSWM(WM_INITDIALOG              )
    IDSWM(WM_COMMAND                 )
    IDSWM(WM_SYSCOMMAND              )
    IDSWM(WM_TIMER                   )
    IDSWM(WM_HSCROLL                 )
    IDSWM(WM_VSCROLL                 )
    IDSWM(WM_INITMENU                )
    IDSWM(WM_INITMENUPOPUP           )
    IDSWM(WM_MENUSELECT              )
    IDSWM(WM_MENUCHAR                )
    IDSWM(WM_ENTERIDLE               )
    IDSWM(WM_MENURBUTTONUP           )
    IDSWM(WM_MENUDRAG                )
    IDSWM(WM_MENUGETOBJECT           )
    IDSWM(WM_UNINITMENUPOPUP         )
    IDSWM(WM_MENUCOMMAND             )
    IDSWM(WM_CTLCOLORMSGBOX          )
    IDSWM(WM_CTLCOLOREDIT            )
    IDSWM(WM_CTLCOLORLISTBOX         )
    IDSWM(WM_CTLCOLORBTN             )
    IDSWM(WM_CTLCOLORDLG             )
    IDSWM(WM_CTLCOLORSCROLLBAR       )
    IDSWM(WM_CTLCOLORSTATIC          )
    IDSWM(WM_MOUSEMOVE               )
    IDSWM(WM_LBUTTONDOWN             )
    IDSWM(WM_LBUTTONUP               )
    IDSWM(WM_LBUTTONDBLCLK           )
    IDSWM(WM_RBUTTONDOWN             )
    IDSWM(WM_RBUTTONUP               )
    IDSWM(WM_RBUTTONDBLCLK           )
    IDSWM(WM_MBUTTONDOWN             )
    IDSWM(WM_MBUTTONUP               )
    IDSWM(WM_MBUTTONDBLCLK           )
    IDSWM(WM_MOUSEWHEEL              )
    IDSWM(WM_MOUSELAST               )
    IDSWM(WM_MOUSELAST               )
    IDSWM(WM_PARENTNOTIFY            )
    IDSWM(WM_ENTERMENULOOP           )
    IDSWM(WM_EXITMENULOOP            )
    IDSWM(WM_NEXTMENU                )
    IDSWM(WM_SIZING                  )
    IDSWM(WM_CAPTURECHANGED          )
    IDSWM(WM_MOVING                  )
    IDSWM(WM_POWERBROADCAST          )
    IDSWM(WM_DEVICECHANGE            )
    IDSWM(WM_MDICREATE               )
    IDSWM(WM_MDIDESTROY              )
    IDSWM(WM_MDIACTIVATE             )
    IDSWM(WM_MDIRESTORE              )
    IDSWM(WM_MDINEXT                 )
    IDSWM(WM_MDIMAXIMIZE             )
    IDSWM(WM_MDITILE                 )
    IDSWM(WM_MDICASCADE              )
    IDSWM(WM_MDIICONARRANGE          )
    IDSWM(WM_MDIGETACTIVE            )
    IDSWM(WM_MDISETMENU              )
    IDSWM(WM_ENTERSIZEMOVE           )
    IDSWM(WM_EXITSIZEMOVE            )
    IDSWM(WM_DROPFILES               )
    IDSWM(WM_MDIREFRESHMENU          )
    IDSWM(WM_IME_SETCONTEXT          )
    IDSWM(WM_IME_NOTIFY              )
    IDSWM(WM_IME_CONTROL             )
    IDSWM(WM_IME_COMPOSITIONFULL     )
    IDSWM(WM_IME_SELECT              )
    IDSWM(WM_IME_CHAR                )
    IDSWM(WM_IME_REQUEST             )
    IDSWM(WM_IME_KEYDOWN             )
    IDSWM(WM_IME_KEYUP               )
    IDSWM(WM_MOUSEHOVER              )
    IDSWM(WM_MOUSELEAVE              )
    IDSWM(WM_CUT                     )
    IDSWM(WM_COPY                    )
    IDSWM(WM_PASTE                   )
    IDSWM(WM_CLEAR                   )
    IDSWM(WM_UNDO                    )
    IDSWM(WM_RENDERFORMAT            )
    IDSWM(WM_RENDERALLFORMATS        )
    IDSWM(WM_DESTROYCLIPBOARD        )
    IDSWM(WM_DRAWCLIPBOARD           )
    IDSWM(WM_PAINTCLIPBOARD          )
    IDSWM(WM_VSCROLLCLIPBOARD        )
    IDSWM(WM_SIZECLIPBOARD           )
    IDSWM(WM_ASKCBFORMATNAME         )
    IDSWM(WM_CHANGECBCHAIN           )
    IDSWM(WM_HSCROLLCLIPBOARD        )
    IDSWM(WM_QUERYNEWPALETTE         )
    IDSWM(WM_PALETTEISCHANGING       )
    IDSWM(WM_PALETTECHANGED          )
    IDSWM(WM_HOTKEY                  )
    IDSWM(WM_PRINT                   )
    IDSWM(WM_PRINTCLIENT             )
    IDSWM(WM_HANDHELDFIRST           )
    IDSWM(WM_HANDHELDLAST            )
    IDSWM(WM_AFXFIRST                )
    IDSWM(WM_AFXLAST                 )
    IDSWM(WM_PENWINFIRST             )
    IDSWM(WM_PENWINLAST              )
    IDSWM(WM_APP                     )
    IDSWM(WM_USER                    )
};

const char * Msg2Str(int msg)
{
    int i  = 0;
    for (i = 0; i < sizeof(msgDesc)/sizeof(msgDesc[0]); i++)
    {
        if (msgDesc[i].msg == msg)
        {
            return msgDesc[i].msgdesc;
        }
    }
    return "UNKOWN";
}
